<?php

class dbaBerichte{

 function dbaBerichte (&$dba) {
   $this->dba = &$dba;
 }

 function addBericht($headline,$rubrik,$status,$on_home,$text){
   if(!$on_home){
     $on_home = 'N';
   }
   return $this->dba->query("insert into ".$this->dba->tableforwarder."_berichte (headline,rubrik,status,on_home,text,datum) values ('$headline','$rubrik','$status','$on_home','$text','".time()."');");
 }

 function updateBericht($id,$headline,$rubrik,$status,$on_home,$text){
   if(!$on_home){
     $on_home = 'N';
   }
   return $this->dba->query("update ".$this->dba->tableforwarder."_berichte set rubrik='$rubrik',headline='$headline',status='$status',on_home='$on_home',text='$text' where id=$id;");
 }

 function updateBerichtStatus($id,$status){
   return $this->dba->query("update ".$this->dba->tableforwarder."_berichte set status='$status' where id=$id;");
 }

 function delBericht($id){
   return $this->dba->query("delete from ".$this->dba->tableforwarder."_berichte where id=$id;");
 }
 
 function getBericht($id){
   $this->dba->query("select * from ".$this->dba->tableforwarder."_berichte where id=$id;");
   return $this->dba->fetch_row_array();
 }

 function getBerichteByRubrik($rubrik){
   $this->dba->query("select * from ".$this->dba->tableforwarder."_berichte where rubrik='$rubrik';");
   return $this->dba->fetch_rows_array();
 }

 function getPubBerichteByRubrik($rubrik){
   $this->dba->query("select * from ".$this->dba->tableforwarder."_berichte where rubrik='$rubrik' AND status='p';");
   return $this->dba->fetch_rows_array();
 }

 function getBerichte(){
   $this->dba->query("select * from ".$this->dba->tableforwarder."_berichte;");
   return $this->dba->fetch_rows_array();
 }

 function getBerichteHome(&$result){
   $check  = $this->dba->query("select * from ".$this->dba->tableforwarder."_berichte where status='p' AND on_home='Y';");
   return $this->dba->fetch_rows_array();
 }
 
}
?>
